package cn.edu.zju.om;

import java.io.IOException;
import java.util.Properties;

import org.htmlparser.Parser;
import org.htmlparser.util.ParserException;

import cn.edu.zju.om.crawler.TaskManager;
import cn.edu.zju.om.data.DAO;
import cn.edu.zju.om.data.ReviewTarget;


public class Main {

	/**
	 * @param args
	 * @throws ParserException 
	 * @throws IOException 
	 */
	public static void main(String[] args) throws ParserException, IOException {

		DAO<ReviewTarget, String> reviewTargetDAO = new DAO<ReviewTarget, String>(ReviewTarget.class);

		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9258919");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9231604");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9240993");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9057812");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9304959");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9211875");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=20032382");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=20464285");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=20534533");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=9157098");
		TaskManager.getInstance().addTask("http://product.dangdang.com/product.aspx?product_id=20675508");
		
		for(int i = 0; i < 5; ++i) {
			Crawler crawler = new Crawler(new DangdangProcessor());

			Thread thread = new Thread(crawler);
			thread.start();
		}
		
		System.in.read();
		
		System.out.println("Exiting...");
		
		Crawler.exit();
		
		TaskManager.getInstance().close();
		
		System.out.println("Database closed.");
		
		System.in.read();

	}

}
